//
//  fmDataModel.m
//  TryShopping
//
//  Created by LiYinDi on 16/6/17.
//  Copyright © 2016年 RuiBen. All rights reserved.
//

#import "fmDataModel.h"
#import "LeftJoinFmdbModel.h"

@implementation fmDataModel
+(instancetype)dataModelWithArray:(NSMutableArray *)array
{
    NSMutableArray *productImageArray=[NSMutableArray array];
    NSMutableArray *productIDArray=[NSMutableArray array];
    NSMutableArray *productItemCodeArray=[NSMutableArray array];
    //    NSMutableArray *productItemTypeArray=[NSMutableArray array];
    NSMutableArray *productNameArray=[NSMutableArray array];
    NSMutableArray *productPriceArray=[NSMutableArray array];
    NSMutableArray *productCountArray=[NSMutableArray array];
    NSMutableArray *productSpecNameArray=[NSMutableArray array];
    NSMutableArray *productSpecIDArray=[NSMutableArray array];
    NSMutableArray *productSpecPriceArray=[NSMutableArray array];
    NSMutableArray *productStockCountArray=[NSMutableArray array];
    for (int i=0; i<array.count; i++) {
        LeftJoinFmdbModel *model=array[i];
        [productIDArray addObject:model.itemId];
        [productItemCodeArray addObject:model.itemCode];
        [productImageArray addObject:model.imageUrlFull];
        [productNameArray addObject:model.itemName];
        if([model.specType intValue]==0)
        {
        [productCountArray addObject:model.mainCount];
        [productPriceArray addObject:model.salePrice];
        }
        else
        {
        [productCountArray addObject:model.specCount];
        [productPriceArray addObject:model.specPrice];
        }
       
        [productSpecNameArray addObject:model.specName];
        [productSpecPriceArray addObject:model.specPrice];
        [productStockCountArray addObject:model.specCount];
        [productSpecIDArray addObject:model.specID];
    }

    
    fmDataModel *dataModel=[[self alloc] init];
    dataModel.productImageArray=[productImageArray mutableCopy];
    dataModel.productIDArray=[productIDArray mutableCopy];
    dataModel.productItemCodeArray=[productItemCodeArray mutableCopy];
    dataModel.productNameArray=[productNameArray mutableCopy];
    dataModel.productPriceArray=[productPriceArray mutableCopy];
    dataModel.productCountArray=[productCountArray mutableCopy];
    dataModel.productSpecNameArray=[productSpecNameArray mutableCopy];
    dataModel.productSpecIDArray=[productSpecIDArray mutableCopy];
    dataModel.productSpecPriceArray=[productSpecPriceArray mutableCopy];
    dataModel.productStockCountArray=[productStockCountArray mutableCopy];
    return dataModel;
}
@end
